package com.itheima.article.service.impl;

import com.itheima.article.pojo.ApArticleConfig;
import com.itheima.article.mapper.ApArticleConfigMapper;
import com.itheima.article.service.ApArticleConfigService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.wemedia.dto.DownOrUpDto;
import org.springframework.stereotype.Service;

/**
 * @description <p>APP已发布文章配置 业务实现</p>
 *
 * @version 1.0
 * @package com.itheima.article.service.impl
 */
@Service
public class ApArticleConfigServiceImpl extends ServiceImpl<ApArticleConfigMapper, ApArticleConfig> implements ApArticleConfigService {

    /**
     * 文章更新上下架
     *
     * @param downOrUpDto
     */
    @Override
    public void downOrUp(DownOrUpDto downOrUpDto) {
        ApArticleConfig updatePojo = new ApArticleConfig();
        // 设置更新的字段值
        // dto.enable=1 代表上架 is_down=0
        // dto.enable=0 代表下架 is_down=1
        updatePojo.setIsDown(downOrUpDto.getEnable()==1?0:1);
        updatePojo.setId(downOrUpDto.getId());
        updateById(updatePojo);
    }
}
